﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace RMS.Models
{
    public partial class Problem
    {
        public decimal AverageRVN
        {
            get
            {
                if (this.ProblemScores.Count == 0)
                {
                    return 0;
                }
                else
                {
                    return this.ProblemScores.Average(x => x.RVN);
                }
            }
        }
        public decimal CompanyRVN(int companyId)
        {
            if (this.ProblemScores.Where(x => x.User.CompanyId != null).Count() == 0)
            {
                return 0;
            }
            else
            {
                return this.ProblemScores.Where(x => x.User.CompanyId.Value == companyId).Average(x=>x.RVN);
            }
        }
    }
}